
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class DmsNetworkLockRuleServiceImpl implements DmsNetworkLockRuleService  {

    @Resource
    private DmsNetworkLockRuleMapper dmsNetworkLockRuleMapper;

    /**
     * 获取 DmsNetworkLockRule 分页列表
     */
    @Transactional
    public IPage getDmsNetworkLockRulePagination( PaginationVo paginationVo, DmsNetworkLockRuleQuery dmsNetworkLockRuleQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<DmsNetworkLockRuleEntity> lqs = new LambdaQueryWrapper();
        dmsNetworkLockRuleMapper.selectPage(page, lqs);

        List<DmsNetworkLockRuleEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 DmsNetworkLockRule 所有数据
     *
    */
    @Transactional
    public List<DmsNetworkLockRuleEntity> getDmsNetworkLockRuleAllList( DmsNetworkLockRuleQuery dmsNetworkLockRuleQuery ) throws Exception {

        LambdaQueryWrapper<DmsNetworkLockRuleEntity> lqs = new LambdaQueryWrapper();
        List<DmsNetworkLockRuleEntity> list = dmsNetworkLockRuleMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 DmsNetworkLockRule 详情
    */
    @Transactional
    public DmsNetworkLockRuleEntity getDmsNetworkLockRuleDetail( Long id) throws Exception {

        DmsNetworkLockRuleEntity dmsNetworkLockRule = dmsNetworkLockRuleMapper.selectById(id);
        return dmsNetworkLockRule;
    }


    /**
     * 新增 DmsNetworkLockRule
     * */
    @Transactional
    public void addDmsNetworkLockRule(DmsNetworkLockRuleVo dmsNetworkLockRuleVo) throws Exception {

        DmsNetworkLockRuleEntity dmsNetworkLockRule = new DmsNetworkLockRuleEntity();
        ReflectionCopy.copyProperties( dmsNetworkLockRule, dmsNetworkLockRuleVo );
        dmsNetworkLockRuleMapper.insert(dmsNetworkLockRule);
        return;
    }


    /**
     * 更新 DmsNetworkLockRule
     * */
    @Transactional
    public void updateDmsNetworkLockRule( DmsNetworkLockRuleVo dmsNetworkLockRuleVo) throws Exception {

        if( dmsNetworkLockRuleVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        DmsNetworkLockRuleEntity dmsNetworkLockRule = new DmsNetworkLockRuleEntity();
        ReflectionCopy.copyProperties( dmsNetworkLockRule, dmsNetworkLockRuleVo );
        dmsNetworkLockRuleMapper.updateById(dmsNetworkLockRule);
        return;
    }

    /**
     * 删除 DmsNetworkLockRule
     * */
    @Transactional
    public void batchRemoveDmsNetworkLockRule( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        dmsNetworkLockRuleMapper.deleteBatchIds(ids);
    }

}

      